/**利用反射改善简单工厂
 * 解决每次增加产品都要改代码的弊端
 * @author weiZhiLin
 * @version 1.0
 * @date 2020/1/6 14:00
 */
public class ReflectFactory {
    public static Object getClass(Class<? extends Phone> clazz) {
        try {
            return Class.forName(clazz.getName()).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
